package com.me.common;

import java.util.ArrayList;
import java.util.List;

public class ToolsList {

    private static final List<Tools> tools = new ArrayList<>();

    public static final String PLUG_LIB_DIR = "plug-lib";

    public static List<Tools> getAll(){
        return tools;
    }

    public static void addTools(Tools tool,Class<?> clazz){
        if(tool == null || tool.url == null){
            throw new RuntimeException("工具为空或url为空");
        }
        tool.url = "jar:"+clazz.getProtectionDomain().getCodeSource().getLocation().toExternalForm().replaceAll("/+","/")+"!/"+tool.url;
        tools.add(tool);
    }

    public static class Tools{
        private String key;
        private String name;
        private String url;
        private String ico;
        private String description;

        public Tools(String key,String name, String url, String ico,String description) {
            this.key = key;
            this.name = name;
            this.url = url;
            this.ico = ico;
            this.description = description;
        }

        public String getKey() {
            return key;
        }

        public void setKey(String key) {
            this.key = key;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getIco() {
            return ico;
        }

        public void setIco(String ico) {
            this.ico = ico;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }
    }

}